import React = require("react");
import { PageProps } from "maishu-chitu-react";

export abstract class BasePage<P extends PageProps, S> extends React.Component<P, S> {

    constructor(props) {
        super(props)

    }

    renderButtns(): React.ReactElement<any,any>[] {
        return [];
    }

    abstract renderView(): React.ReactElement<any,any>;

    render() {
        let buttons = this.renderButtns();
        let view = this.renderView();
        return <div>
            <ul className="clearfix">
                <button className="btn btn-sm btn-primary pull-right"
                    onClick={() => this.props.app.back()}>
                    <i className="icon-reply"></i><span>返回</span>
                </button>
                {buttons.map((o, i) =>
                    <li key={i} className="pull-right">
                        {o}
                    </li>
                )}
            </ul>
            <hr style={{ margin: 0, marginTop: -2 }} />
            {view}
        </div>
    }
}